package de.karlNet.sambamanager.ldapController.ssl;

import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.springframework.stereotype.Component;


@Component
public class SSLOverride {

	public SSLOverride() {
		try {
		    SSLContext ctx = SSLContext.getInstance("TLS");
		    X509TrustManager tm = new X509TrustManager() {

		        public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException {
		        }

		        public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException {
		        }

		        public X509Certificate[] getAcceptedIssuers() {
		            return null;
		        }
		    };
		    ctx.init(null, new TrustManager[]{tm}, null);
		    SSLContext.setDefault(ctx);
		} catch (Exception ex) {
		    ex.printStackTrace();
		}
	}
}
